//
//  CustomHeaderView.m
//  APP_login
//
//  Created by edz on 7/11/21.
//  Copyright © 2021 baicai. All rights reserved.
//

#import "CustomHeaderView.h"
#import "SectionModel.h"
#import "Masonry.h"

@interface  CustomHeaderView()
@property (nonatomic, strong) UILabel *titleLable;
@property (nonatomic, strong) UIButton *buttom;
@property(strong, nonatomic) UIColor *titleColor;

@end


@implementation CustomHeaderView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self titleLable];
        [self buttom];
    }
    return self;
}

- (UILabel *)titleLable{
    if (!_titleLable) {
        _titleLable = [[UILabel alloc] init];
        [self addSubview:_titleLable];
        [_titleLable mas_makeConstraints:^(MASConstraintMaker *make){
            make.top.left.mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(140, 40));
        }];
        _titleLable.font = [UIFont systemFontOfSize:20];
    }
    return _titleLable;
}

- (UIButton *)buttom{
    if (!_buttom) {
        _buttom = [UIButton buttonWithType:UIButtonTypeSystem];
        [self addSubview:_buttom];
        [_buttom mas_makeConstraints:^(MASConstraintMaker *make){
            make.right.mas_equalTo(-30);
            make.top.mas_equalTo(7);
            make.size.mas_equalTo(CGSizeMake(50, 25));
        }];
        [_buttom setTitle:@"更多" forState:UIControlStateNormal];
        [_buttom setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [_buttom addTarget:self action:@selector(moreButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _buttom;
}


- (void)setModel:(SectionModel *)model{
    _titleLable.text = model.henderTitle;
}

- (void)getTitleColer:(UIColor*) color{
    _titleLable.textColor = color;
}

- (void) moreButtonClick:(UIButton*)button{
    if (button.tag == 117) {
        NSLog(@"考证");
    }
    if (button.tag == 116) {
        NSLog(@"A爱好");
    }
}
@end
